# 字符串的计算
str = "programming learning"

str2 = "i have done " + str  # 拼接
print(str2)

str3 = str * 2
print(str3)

# 字符串格式化
name = "joe"
time = 1
# f-string 新特性
print(f"{name}, have done {str} for {time} years")

# format
str5 = '{}, have done {} for {} years'.format(name, str, time)
print(str5)

# 格式化字符填空
str4 = '%s, have done %s for %d years' % (name, str, time)
print(str4)

# 乘法表

for x in range(1, 10):
  for y in range(1, x+1):
    print(f'{y} * {x} = {x*y}', end="\t")
  print()

# 打印乘法表
# for x in range(1, 10):  # 外层循环控制行
#     for y in range(1, x + 1):  # 内层循环控制列
#         print(f"{y} * {x} = {x * y}", end="\t")  # 使用制表符对齐
#     print()  # 每一行结束后换行
